package com.example.yiwei.crm.view.activity.JYCoordingActivity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.bigkoo.pickerview.TimePickerView;
import com.example.yiwei.crm.R;
import com.example.yiwei.crm.base.baseClass;
import com.example.yiwei.crm.data.GetAppointment;
import com.example.yiwei.crm.data.GetAreData;
import com.example.yiwei.crm.entity.ApointmentEntity;
import com.example.yiwei.crm.entity.BZFLEntity;
import com.example.yiwei.crm.entity.HospitalEntity;
import com.example.yiwei.crm.entity.KSEntity;
import com.example.yiwei.crm.json.ApointmentJson;
import com.example.yiwei.crm.json.YYSpinnerJson;
import com.example.yiwei.crm.util.NetWorkUtils;
import com.example.yiwei.crm.util.SC;
import com.example.yiwei.crm.view.Class.listviewClass.ApoinAdapter;
import com.example.yiwei.crm.view.activity.areActivity.ProvinceActivity;
import com.example.yiwei.crm.view.activity.coordinationActivity.SeacherMYDActivity;
import com.example.yiwei.crm.view.activity.coordinationActivity.SearchCoordinationActivity;
import com.example.yiwei.crm.view.activity.jtCustomer.JDcoorActivity;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

public class SearchJDActivity extends AppCompatActivity {
    private EditText name,phone,manager,yynumber;
    private Spinner sp_pname,sp_cname,sp_aname,sp_yy,sp_bz,sp_jb,sp_qdfl,sp_qdly,sp_jzzt;
    private Date date1, date2, date3, date4, date5, date6, date7, date8;
    private TextView tv1,tv2,tv3,tv4,tv5,tv6,tv7,tv8;
    private TimePickerView mpv;
    private TimePickerView mpv1;
    private TimePickerView mpv2;
    private TimePickerView mpv3;
    private TimePickerView mpv4;
    private TimePickerView mpv5;
    private TimePickerView mpv6;
    private TimePickerView mpv7;
    private ImageView img_commit;
    String pid;
    String pname;
    String cid;
    String cname;
    String aid;
    String state_name;
    String aname;
    private ApointmentEntity apo;
    private ArrayList<ArrayList<ArrayList<String>>> mListArea = new ArrayList<ArrayList<ArrayList<String>>>();
    private String  create_time,create_time1,yy_time,yy_time1,jj_time,jj_time1,
            sure_time,sure_time1;
    private Button btn_create_time,btn_create_time1,btn_yy_time,btn_yy_time1,btn_jj_time,btn_jj_time1,
            btn_sure_time,btn_sure_time1;
    private List<HospitalEntity> list1;
    private List<KSEntity> list2;
    private List<BZFLEntity> list4;
    private List<BZFLEntity> list3;
    private List<BZFLEntity> list5;
    private List<BZFLEntity> list6;
    private SharedPreferences sp;
    private ArrayAdapter adapter ,adapter2,adapter3,adapter4,adapter5,adapter6,adapter7,adapter8;
    String hospital_name,hospital_bianma,department_name,department_bianma,disease_category,disease,disease_bianma,qdfl,qdly;
    int disease_category_id,disease_id;
    List<String> hospital_list,state_list,disease_category_list,disease_list,qdfl_list,qdly_list,jd_list;
    int qdfl_id,qdly_id;
    private TextView txt_province;
    private  Button btn_province;
    String state_id;
    private List<ApointmentEntity> list;
    private ApoinAdapter adapter1;
    private ImageView img_luru,img_search,img_tj,img_me,img_back;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_jd);
        img_back= (ImageView) findViewById(R.id.detailed_doc_img_back);
        img_luru= (ImageView) findViewById(R.id.item_image_lr);
        img_search= (ImageView) findViewById(R.id.item_image_cx);
        img_me= (ImageView) findViewById(R.id.item_image_w);
        img_tj= (ImageView) findViewById(R.id.item_image_tj);
        img_commit= (ImageView) findViewById(R.id.commit);
        name = (EditText) findViewById(R.id.name);
        phone = (EditText) findViewById(R.id.phone);
        manager = (EditText) findViewById(R.id.manager_name);
        yynumber = (EditText) findViewById(R.id.yy_number);
        sp_yy = (Spinner) findViewById(R.id.hospital);
        sp_bz = (Spinner) findViewById(R.id.sp_bingzhong);
        sp_jb = (Spinner) findViewById(R.id.sp_jb);
        sp_qdfl = (Spinner) findViewById(R.id.sp_qdfl);
        sp_qdly = (Spinner) findViewById(R.id.sp_qdly);
        sp_jzzt = (Spinner) findViewById(R.id.sp_jzzt);
        tv1 = (TextView) findViewById(R.id.cstime);
        tv2 = (TextView) findViewById(R.id.cetime);
        tv3 = (TextView) findViewById(R.id.yytime);
        tv4 = (TextView) findViewById(R.id.eyytime);
        tv5 = (TextView) findViewById(R.id.sjztime);
        tv6 = (TextView) findViewById(R.id.ejztime);
        tv7 = (TextView) findViewById(R.id.qrtime);
        tv8 = (TextView) findViewById(R.id.eqrtime);
        btn_create_time= (Button) findViewById(R.id.cstime_show);
        btn_create_time1= (Button) findViewById(R.id.cetime_show);
        btn_yy_time= (Button) findViewById(R.id.cyytime_show);
        btn_yy_time1= (Button) findViewById(R.id.eyytime_show);
        btn_jj_time= (Button) findViewById(R.id.sjztime_show);
        btn_jj_time1= (Button) findViewById(R.id.ejztime_show);
        btn_sure_time= (Button) findViewById(R.id.qrtime_show);
        btn_sure_time1= (Button) findViewById(R.id.eqrtime_show);
        txt_province= (TextView) findViewById(R.id.manyidu_search_province);
        btn_province= (Button) findViewById(R.id.manyidu_search_province_btn_show);
        img_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        img_tj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(SearchJDActivity.this, JDcoorActivity.class);
                intent.putExtra("tt","tt");
                startActivity(intent);
                finish();

            }
        });
        img_me.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(SearchJDActivity.this, JDcoorActivity.class);
                intent.putExtra("me","me");
                startActivity(intent);
                finish();
            }
        });
        img_luru.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(SearchJDActivity.this, JDcoorActivity.class);
                startActivity(intent);
                finish();
            }
        });
        img_search.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(SearchJDActivity.this, JDcoorActivity.class);
                intent.putExtra("ii","ii");
                startActivity(intent);
                finish();
            }
        });
        sp = getSharedPreferences("login", Context.MODE_PRIVATE);
        //创建选择器
        mpv = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar = Calendar.getInstance();
        mpv.setRange(calendar.get(Calendar.YEAR) - 100, calendar.get(Calendar.YEAR) + 100);
        //插入时间
        mpv.setTime(new Date());
        //选择监听
        mpv.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date) {
                date1 = date;
                create_time=getTime(date);
                tv1.setText(create_time);
            }
        });
        btn_create_time.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv.show();
            }
        });

        //创建选择器
        mpv1 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar1 = Calendar.getInstance();
        mpv1.setRange(calendar1.get(Calendar.YEAR) - 100, calendar1.get(Calendar.YEAR) + 100);
        //插入时间
        mpv1.setTime(new Date());
        //选择监听
        mpv1.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date2 = date;
                create_time1=getTime(date);
                tv2.setText(create_time1);
            }
        });
        btn_create_time1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv1.show();
            }
        });

        //创建选择器
        mpv2 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar2 = Calendar.getInstance();
        mpv2.setRange(calendar2.get(Calendar.YEAR) - 100, calendar2.get(Calendar.YEAR) + 100);
        //插入时间
        mpv2.setTime(new Date());
        //选择监听
        mpv2.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date3 = date;
                yy_time=getTime(date);
                tv3.setText(yy_time);
            }
        });
        btn_yy_time.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv2.show();
            }
        });

        //创建选择器
        mpv3 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar3 = Calendar.getInstance();
        mpv3.setRange(calendar3.get(Calendar.YEAR) - 100, calendar3.get(Calendar.YEAR) + 100);
        //插入时间
        mpv3.setTime(new Date());
        //选择监听
        mpv3.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date4 = date;
                yy_time1=getTime(date);
                tv4.setText(yy_time1);
            }
        });
        btn_yy_time1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv3.show();
            }
        });

        //创建选择器
        mpv4 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar4 = Calendar.getInstance();
        mpv4.setRange(calendar4.get(Calendar.YEAR) - 100, calendar4.get(Calendar.YEAR) + 100);
        //插入时间
        mpv4.setTime(new Date());
        //选择监听
        mpv4.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date5 = date;
                jj_time=getTime(date);
                tv5.setText(jj_time);
            }
        });
        btn_jj_time.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv4.show();
            }
        });

        //创建选择器
        mpv5 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar5 = Calendar.getInstance();
        mpv5.setRange(calendar5.get(Calendar.YEAR) - 100, calendar5.get(Calendar.YEAR) + 100);
        //插入时间
        mpv5.setTime(new Date());
        //选择监听
        mpv5.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date6 = date;
                jj_time1=getTime(date);
                tv6.setText(jj_time1);
            }
        });
        btn_jj_time1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv5.show();
            }
        });


        //创建选择器
        mpv6 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar6 = Calendar.getInstance();
        mpv6.setRange(calendar6.get(Calendar.YEAR) - 100, calendar6.get(Calendar.YEAR) + 100);
        //插入时间
        mpv6.setTime(new Date());
        //选择监听
        mpv6.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date7 = date;
                sure_time=getTime(date);
                tv7.setText(sure_time);
            }
        });
        btn_sure_time.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv6.show();
            }
        });

        //创建选择器
        mpv7 = new TimePickerView(this, TimePickerView.Type.YEAR_MONTH_DAY);
        //设置时间范围
        Calendar calendar7 = Calendar.getInstance();
        mpv7.setRange(calendar7.get(Calendar.YEAR) - 100, calendar7.get(Calendar.YEAR) + 100);
        //插入时间
        mpv7.setTime(new Date());
        //选择监听
        mpv7.setOnTimeSelectListener(new TimePickerView.OnTimeSelectListener() {

            @Override
            public void onTimeSelect(Date date) {
                date8 = date;
                sure_time1=getTime(date);
                tv8.setText(sure_time1);
            }
        });
        btn_sure_time1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mpv7.show();
            }
        });
        state_list=new ArrayList<>();
        state_list.add(0,"");
        state_list.add(1,"未就诊");
        state_list.add(2,"已就诊");

        adapter2 = new ArrayAdapter(SearchJDActivity.this, R.layout.spinner_display_style, R.id.txtvwSpinner, state_list);
        adapter2.setDropDownViewResource(R.layout.spinner_dropdown_style);
        sp_jzzt.setAdapter(adapter2);
        sp_jzzt.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                if (position>0){
                    state_name=state_list.get(position);
                    if (state_name.equals("未就诊")){
                        state_id="AA";
                    }else if (state_name.equals("已就诊")){
                        state_id="BB";
                    }
//                    Toast.makeText(SeacherMYDActivity.this, state_id, Toast.LENGTH_SHORT).show();
                }

            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });

        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc = new SC();
                JSONObject object = sc.storage(sp);
                String json = object.toString();
                String result = NetWorkUtils.getCount(baseClass.find_hospital_add_yy_URL, json);
                list1= YYSpinnerJson.getHospital(result);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        hospital_list= new ArrayList<>();
                        hospital_list.add("");
                        for (int i2=0;i2<list1.size();i2++){
                            hospital_list.add( list1.get(i2).getName());
                        }
                        adapter = new ArrayAdapter(SearchJDActivity.this, R.layout.spinner_display_style, R.id.txtvwSpinner, hospital_list);
                        adapter.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        sp_yy.setAdapter(adapter);
                        sp_yy.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position>0){
                                    hospital_name=list1.get(position-1).getName();
                                    hospital_bianma = list1.get(position-1).getBianma();
                                }
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                });
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc1 = new SC();
                JSONObject object3 = sc1.storage(sp);
                String json2 = object3.toString();
                String result2 = NetWorkUtils.getCount(baseClass.find_BZFL_URL,json2);
                list3 = YYSpinnerJson.getBZFL(result2);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        disease_category_list= new ArrayList<>();
                        disease_category_list.add("");
                        for (int i2=0;i2<list3.size();i2++){
                            disease_category_list.add( list3.get(i2).getName());
                        }
                        adapter3 = new ArrayAdapter(SearchJDActivity.this, R.layout.spinner_display_style, R.id.txtvwSpinner,disease_category_list);
                        adapter3.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        sp_bz.setAdapter(adapter3);
                        sp_bz.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position>0){
                                    disease_category=list3.get(position-1).getName();
                                    disease_category_id = list3.get(position-1).getId();
                                }
                                if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                    for (int i = 0;i<disease_category_list.size();i++){
                                        if (disease_category_list.get(i).equals(apo.getDisease_category())){
                                            sp_bz.setSelection(i);
                                        }
                                    }
                                }
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        SC sc = new SC();
                                        JSONObject object2 = sc.storage(sp);
                                        try {
                                            object2.put("AKB01",disease_category_id);
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        Log.d("a",object2.toString());
                                        String json = object2.toString();
                                        Log.d("a",json);
                                        String result = NetWorkUtils.getCount(baseClass.find_BZ_URL, json);
                                        list4 = YYSpinnerJson.getBZ(result);
                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                disease_list = new ArrayList<String>();
                                                disease_list.add("");
                                                for (int i2=0;i2<list4.size();i2++){
                                                    disease_list.add( list4.get(i2).getName());
                                                }
                                                adapter4 = new ArrayAdapter(SearchJDActivity.this, R.layout.spinner_display_style, R.id.txtvwSpinner, disease_list);
                                                adapter4.setDropDownViewResource(R.layout.spinner_dropdown_style);
                                                sp_jb.setAdapter(adapter4);
                                                sp_jb.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                                    @Override
                                                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                                        if (position>0){
                                                            disease=list4.get(position-1).getName();
                                                            disease_id = list4.get(position-1).getId();
                                                        }
                                                        if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                                            for (int i = 0;i<disease_list.size();i++){
                                                                if (disease_list.get(i).equals(apo.getDisease())){
                                                                    sp_jb.setSelection(i);
                                                                }
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void onNothingSelected(AdapterView<?> parent) {

                                                    }
                                                });
                                            }
                                        });
                                    }
                                }).start();
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }
                });
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                SC sc1 = new SC();
                JSONObject object3 = sc1.storage(sp);
                String json2 = object3.toString();
                String result2 = NetWorkUtils.getCount(baseClass.find_QDFL_URL,json2);
                list5 = YYSpinnerJson.getQDFL(result2);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        qdfl_list= new ArrayList<>();
                        qdfl_list.add("");
                        for (int i2=0;i2<list5.size();i2++){
                            qdfl_list.add(list5.get(i2).getName());
                        }
                        adapter5 = new ArrayAdapter(SearchJDActivity.this, R.layout.spinner_display_style, R.id.txtvwSpinner, qdfl_list);
                        adapter5.setDropDownViewResource(R.layout.spinner_dropdown_style);
                        sp_qdfl.setAdapter(adapter5);
                        sp_qdfl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                            @Override
                            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                if (position>0){
                                    qdfl=list5.get(position-1).getName();
                                    qdfl_id = list5.get(position-1).getId();
                                }
                                if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                    for (int i = 0;i<qdfl_list.size();i++){
                                        if (qdfl_list.get(i).equals(apo.getClue_channel_classification())){
                                            sp_qdfl.setSelection(i);
                                        }
                                    }
                                }
                                new Thread(new Runnable() {
                                    @Override
                                    public void run() {
                                        SC sc = new SC();
                                        JSONObject object2 = sc.storage(sp);
                                        try {
                                            object2.put("AKC01",qdfl_id);
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                        }
                                        Log.d("a",object2.toString());
                                        String json = object2.toString();
                                        Log.d("a",json);
                                        String result = NetWorkUtils.getCount(baseClass.find_QD_URL, json);
                                        list6 = YYSpinnerJson.getQDLY(result);

                                        runOnUiThread(new Runnable() {
                                            @Override
                                            public void run() {
                                                qdly_list = new ArrayList<String>();
                                                qdly_list.add("");
                                                for (int i2=0;i2<list6.size();i2++){
                                                    qdly_list.add( list6.get(i2).getName());
                                                }
                                                adapter6 = new ArrayAdapter(SearchJDActivity.this, R.layout.spinner_display_style, R.id.txtvwSpinner, qdly_list);
                                                adapter6.setDropDownViewResource(R.layout.spinner_dropdown_style);
                                                sp_qdly.setAdapter(adapter6);
                                                sp_qdly.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                                                    @Override
                                                    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                                                        if (position>0){
                                                            qdly=list6.get(position-1).getName();
                                                            qdly_id = list6.get(position-1).getId();
                                                        }
                                                        if ("updata".equals(getIntent().getStringExtra("TAG"))){
                                                            for (int i = 0;i<qdly_list.size();i++){
                                                                if (qdly_list.equals(apo.getClue_channel_source())){
                                                                    sp_qdly.setSelection(i);
                                                                }
                                                            }
                                                        }
                                                    }
                                                    @Override
                                                    public void onNothingSelected(AdapterView<?> parent) {

                                                    }
                                                });
                                            }
                                        });
                                    }
                                }).start();
                            }
                            @Override
                            public void onNothingSelected(AdapterView<?> parent) {

                            }
                        });
                    }                });
            }
        }).start();

        btn_province.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(SearchJDActivity.this, ProvinceActivity.class);
                startActivity(intent);
            }
        });
        img_commit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View view) {

                            Intent intent=new Intent(SearchJDActivity.this,JYCoorJDActivity.class);
                            intent.putExtra("KAA02",name.getText().toString());
                            intent.putExtra("KLA06",phone.getText().toString());
                            intent.putExtra("KAA09N",manager.getText().toString());
                            intent.putExtra("KAA23",pid);
                            intent.putExtra("KAA24",cid);
                            intent.putExtra("KAA25",aid);
                            intent.putExtra("CTS01B",tv1.getText().toString());
                            intent.putExtra("CTS01E",tv2.getText().toString());
                            intent.putExtra("KYA11",yynumber.getText().toString());
                            intent.putExtra("UAA02N",hospital_bianma);
                            intent.putExtra("AKB01",disease_category_id);
                            intent.putExtra("AKM01",disease_id);
                            intent.putExtra("AKC01",qdfl_id);
                            intent.putExtra("AKD01",qdly_id);
                            intent.putExtra("KYA02_B",tv3.getText().toString());
                            intent.putExtra("KYA02_E",tv4.getText().toString());
                            intent.putExtra("KYA13F",state_id);
                            intent.putExtra("KYA09_B",tv5.getText().toString());
                            intent.putExtra("KYA09_E",tv6.getText().toString());
                            intent.putExtra("KYA76_B",tv7.getText().toString());
                            intent.putExtra("KYA76_E",tv8.getText().toString());
                            startActivity(intent);
                            finish();
            }
        });
    }
    public static String getTime(Date date) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        return format.format(date);
    }
    @Override
    protected void onRestart() {
        super.onRestart();
        if (GetAreData.pname!=null){
            pid = GetAreData.pid;
            pname = GetAreData.pname;
            cid = GetAreData.cid;
            cname = GetAreData.cname;
            aid = GetAreData.aid;
            aname = GetAreData.aname;
            txt_province.setText(pname+cname+aname);
        }
    }

}
